<template>
	<div>
		<yh-select-tree
			ref="treeSelect" v-model="value" @nodeClick="valueChange" :options="orgData"
		></yh-select-tree>
	</div>
</template>

<script>
import YhSelectTree from "@/components/xunheng/yhTreeSelect";
export default {
	name: "yhOrganizationSelect",
	components: {YhSelectTree},
	props:['modelValue'],
	emits:['update:modelValue'],
	data(){
		return{
			orgData:[],
			value:null,
		}
	},
	mounted() {
		this.init()
	},
	methods:{
		async init(){
			var res = await this.$API.system.organization.list.get();
			this.orgData = res.data
			if(!this.modelValue)return;
			this.value = this.modelValue.id
		},
		valueChange(data){
			this.$emit('update:modelValue',{id:data.id,title:data.title})
		}
	}
}
</script>

<style scoped>

</style>
